﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Artech.Core.Wcf
{
    internal class HeaderNameResolver
    {
        public string Namespace { get; private set; }
        public HeaderNameResolver(string ns)
        {
            this.Namespace = ns;
        }

        public string GetName(string headerName)
        {
            string prefix = Namespace + ".";
            if (headerName.StartsWith(prefix))
            {
                return headerName.Substring(prefix.Length);
            }
            return null;
        }

        public string GetHeaderName(string name)
        {
            return string.Format("{0}.{1}", Namespace, name);
        }

        public IEnumerable<string> GetAllHeaderNames(IEnumerable<string> headerNames)
        {
            return headerNames.Where(headerName => headerName.StartsWith(Namespace));
            }
    }
}
